package vn.bus.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import vn.bus.dto.QuerieDTO;

public class QuerieDAO {

	public ArrayList<QuerieDTO> getAllQueries(Connection connection) throws Exception
	{
		ArrayList<QuerieDTO> allQueries = new ArrayList<QuerieDTO>();
		try
		{
			PreparedStatement ps = connection.prepareStatement("SELECT * FROM queries");
			ResultSet rs = ps.executeQuery();
			while(rs.next())
			{
				QuerieDTO Queries = new QuerieDTO();
				Queries.setId(rs.getInt("id"));
				Queries.setSource(rs.getString("source"));
				Queries.setTarget(rs.getString("target"));
				allQueries.add(Queries);
			}
			return allQueries;
		}
		catch(Exception e)
		{
			throw e;
		}
	}
}
